package com.pioneer.sparrowdb.planner.plan;

import com.pioneer.sparrowdb.storage.Tuple;

public abstract class PlanNode {

    /**
     * This method is responsible for computing critical details about the plan
     * node, such as the schema of the results that are produced, the estimated
     * cost of evaluating the plan node (and its children), and statistics
     * describing the results produced by the plan node.
     */
    public abstract void prepare();

    /**
     * Gets the next tuple that fulfills the conditions for this plan node.
     * If the node has a child, it should call getNextTuple() on the child.
     * If the node is a leaf, the tuple comes from some external source such
     * as a table file, the network, etc.
     *
     * @return the next tuple to be generated by this plan, or <tt>null</tt>
     * if the plan has finished generating plan nodes.
     * @throws IllegalStateException if a plan node is not properly initialized
     */
    public abstract Tuple getNextTuple() throws IllegalStateException;
}
